<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>欢迎登录/华硕ASUS商城</title>
    <script src="./js/vue.js"></script>
    <link rel="stylesheet" href="./css/reset.css">
    <link rel="stylesheet" href="./css/login/index.css">
</head>

<body>
    <div id="app">
        <div class="header"><a href="/index"><img src="./img/login/logo.png" alt=""></a></div>
        <div class="containers">
            <div class="leftbox">
                <ul>
                    <li><img src="./img/login/login_big.jpg" alt=""></li>
                </ul>
            </div>
            <div class="rightbox">
                <form action="" class="login">
                    <h2>登录</h2>
                    <p class="part">
                        <input type="text" name="username" v-model="username" placeholder="用户名/手机号">
                    </p>
                    <p class="part">
                        <input type="password" name="password" v-model="password" placeholder="密码">
                    </p>
                    <div class="checked">
                        <input type="checkbox" name="rule" v-model="checked">
                        <p>我已阅读并同意<span>ASUS条款</span>&<span>隐私政策</span>&<span>隐私说明</span>&<span>华硕会员服务隐私说明</span></p>
                    </div>
                    <div class="btn" @click="login">登录</div>
                    <div class="more">
                        <a href="#" class="forget">忘记密码</a>
                        <a href="./reg" class="reg">注册账号</a>
                    </div>
                    <div class="other">
                        <p>其他登录方式</p>
                        <img src="./img/login/weixin.png" alt="">
                    </div>

                    <div class="rightTop">
                        <img src="./img/login/code1.png" alt="">
                    </div>
                </form>
                <ul class="codeBox">
                    <li><img src="./img/login/14555054505248.png" alt=""></li>
                    <li><img src="./img/login/17321648564953.png" alt=""></li>
                </ul>
            </div>
        </div>
        <div class="load" style="display: none;"><img src="./img/login/loading.gif" alt=""></div>
    </div>

    <script src="./js/axios.js"></script>
    <!-- <script src="./js/layer/layer.js"></script> -->
    <script>
        const vm = new Vue({
            el: "#app",
            data() {
                return {
                    username: '',
                    password: '',
                    checked: false
                }
            },
            methods: {
                login() {
                    console.log(this.checked);
                    if (this.checked) {
                        axios.post('/users/login', {
                            username: this.username,
                            password: this.password,
                        }).then(res => {
                            console.log(res);
                            if (res.data.code == 200) {
                                // console.log(res);
                                // localStorage.setItem("user", JSON.stringify(res.data.data[0]))
                                localStorage.setItem("token", res.data.token)
                                location = './index'
                            } else {
                                alert(res.data.msg)
                            }
                        })
                    } else {
                        alert('请先同意条款')
                    }
                }
            },
        })
    </script>
</body>

</html>